//数组扁平化并去重
function flatten(result, arr) {
  //如果是基本数据类型直接进属组
  if(typeof arr !== 'object' && arr !== null){
    result.push(arr)
    return
  }
  //递归
  arr.forEach(item => {
    flatten(result, item)
  })
  return result
}

function flatten1(arr) {
  while (arr.some(item => Array.isArray(item))) {
    arr = [].concat(...arr)
  }
  return arr
}

console.log([...new Set(flatten([], [1,2,[3,4,5,[6,7],8],9,10,[11,[12,13]]]))])
console.log([...new Set(flatten1([1,2,[3,4,5,[6,7],8],9,10,[11,[12,13]]]))])

